package com.stylefeng.guns.modular.flagglory.warpper;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.common.persistence.dao.DepartmentMapper;
import com.stylefeng.guns.common.persistence.dao.InvitationCodeMapper;
import com.stylefeng.guns.common.persistence.model.Department;
import com.stylefeng.guns.common.persistence.model.InvitationCode;
import com.stylefeng.guns.core.base.warpper.BaseControllerWarpper;
import com.stylefeng.guns.core.util.SpringContextHolder;

import java.util.Map;

/**
 * 部门列表的包装
 *
 * @author fengshuonan
 * @date 2017年4月25日 18:10:31
 */
public class InvitationCodeWarpper extends BaseControllerWarpper {
    private InvitationCodeMapper invitationCodeMapper = SpringContextHolder.getBean(InvitationCodeMapper.class);

    public InvitationCodeWarpper(Object list) {
        super(list);
    }


    @Override
    public void warpTheMap(Map<String, Object> map) {
        Integer deptId = (Integer) map.get("id");
        EntityWrapper<InvitationCode> entityWrapper = new EntityWrapper<>();
        entityWrapper.where("deptId=" + deptId).and("available=true");
        Integer availableNum = invitationCodeMapper.selectCount(entityWrapper);
        entityWrapper = new EntityWrapper<>();
        entityWrapper.where("deptId=" + deptId).and("available=false");
        Integer unAvailableNum = invitationCodeMapper.selectCount(entityWrapper);
        map.put("availableNum", availableNum);
        map.put("unAvailableNum", unAvailableNum);
    }

}
